<SCRIPT LANGUAGE="JavaScript"> 
    var xx = 100;
    var yy = 100;
    var tx = 0;
    var ty = 0;
    var dx = 0;
    var dy = 0;
    var klik = 0;
    
    function make_slip(event)
    {  
        if(event)
        {
            xx=event.clientX;
            yy=event.clientY;
        }
        else
        {
            xx=100;
            yy=100;
        }
        klik=0;
        
        var temp = document.getElementById('slip');
        temp.style.position = 'absolute';
        temp.style.borderTop = '4px solid #ddd';
        temp.style.borderLeft = '4px solid #ddd';
        temp.style.borderBottom = '4px solid #aaa';
        temp.style.borderRight = '4px solid #aaa';
            
        temp.style.top = yy+'px';
        temp.style.left = xx+'px';
        temp.style.width = 'auto';
        temp.style.height = 'auto';
        temp.style.backgroundColor = 'white';
    }
    
    function close_slip()
    {  
        document.getElementById('slip').innerHTML = '';
        document.getElementById('slip').style.border = 'none';
    }
    
    function tekan(event)
    {
        klik = 1;
        tx=event.clientX;
        ty=event.clientY;
    }
    
    function gerak(event)
    {
        if(klik==1)
        {
            dx=event.clientX-tx;
            dy=event.clientY-ty;
            
            xx = xx + dx;
            yy = yy + dy;
            
            document.getElementById('slip').style.top = yy+'px';
            document.getElementById('slip').style.left = xx+'px';      
            
            tx=event.clientX;
            ty=event.clientY;
        }
    }    
    
    function lepas()
    {
        klik=0;
    }
  
    function gocover()
    {
        if (confirm('Are you sure you want to continue the action ?\nIf you think the template is not suitable for you, you can undo the change at the editor.'))
        {
            var isi=document.getElementById('company_name').value+"\n<br>\n<br>"+document.getElementById('now').value+"\n<br>\n<br>To Whom It May Concern:\n<br>Application for the position of "+document.getElementById('position').value+" \n<br>I am interested in applying for the above position advertised in ITjobz.com on "+document.getElementById('created').value+". My resume is attached for your review.\n<br>I am confident that my skills and past experience could make great contributions to your organization. Therefore I would appreciate the opportunity to discuss my qualifications for this position in greater detail with you in person at your earliest convenience.\n<br>Thank you for your consideration and I look forward to hearing from you.\n<br>\n<br> Yours sincerely,\n<br>\n<br>"+document.getElementById('first_name').value+" "+document.getElementById('last_name').value;
            document.getElementById('ApplicantCover').value=isi;
        }
    }
    
    function open_win2(id)
    {
        window.open('jobs/view/'+id,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, top=100, left=100, width=930, height=600");
    }

    function open_win(id)
    {
        window.open('employers/view/'+id,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes, top=100, left=100, width=930, height=600");
    }    
  
</SCRIPT>


<?php
echo "<div class='form'>";
    echo $this->element('myfunction'); 
    echo "<h2> My Index Page </h2>";
    echo "<hr color='#2A7EF7'>";   

    if($assistant['status']!=0)
    {   
        echo ":. Asisten Anda telah menemukan <b>".$jumlah_jobs."</b> job(s) yang cocok untuk profil asisten Anda";
        if(count($jobs)>0)
        { echo " ".$html->link(" <img src='img/rss.jpg' style='width:50px;height:50px' align='middle'> ", array('action' => 'jobalert.rss'),array(),false,false); }
        else
        { echo "<br> &nbsp &nbsp &nbsp &nbsp ( <span class='info'> Mungkin profil asisten Anda terlalu dibatasi, mengedit profilnya ".$html->link('[ Here ]',array('controller'=>'assistants','action'=>'index'))."</span> )" ; }
        echo "<br>";
        
        if(count($jobs)>0)
        {
            echo "<table class='jobs' cellpadding=0 cellspacing=0>";
                echo "<tr><th width='100px'>Posted Date</th><th width='220px'>Posisi</th><th width='150px'>Nama Perusahaan</th><th width='120px'>Lokasi</th><th width='100px'>Tingkat Karir</th><th width='80px'>Pengalaman</th><th width='120px'>Gaji</th><th width='120px'>Action</th></tr>";
                foreach($jobs as $job)
                {
                    echo "<tr>";
                    echo "<td>".mydate($job['jobs']['created'])."</td>";
                   // echo "<td>".$html->link($job['jobs']['position'], array('controller' => 'jobs','action' => 'view','id' => $job['jobs']['id']),array('class'=>'blue'))." &nbsp";
                    echo "<td> <a href='javascript:open_win2(".$job['jobs']['id'].")' class='sky'>".$job['jobs']['position']."</a> &nbsp";
                    echo $ajax->link("<img src='img/hint.gif'>",
                                    array('controller'=>'jobs','action'=>'detail',$job['jobs']['id']),
                                    array('update'=>'slip','complete'=>"make_slip(event);"),
                                    null,false
                                    
                                 ); 
                    echo "</td>";
                    echo "<td><a href='javascript:open_win(".$job['jobs']['employer_id'].")'>".$job['employers']['company_name']."</a></td>";
                    echo "<td>".$job['cities']['name']."</td>";
                     
                    if($job['jobs']['entry']==1)
                    echo "<td>Entry Level</td>";
                    if($job['jobs']['middle']==1)
                    echo "<td>Middle</td>";
                    if($job['jobs']['senior']==1)
                    echo "<td>Senior</td>";
                    if($job['jobs']['top']==1)
                    echo "<td>Top</td>";

                    echo "<td>".$job['jobs']['experience']."</td>";

                    if($job['jobs']['salary']==0)
                    { $temp=SALARY_0; }
                    if($job['jobs']['salary']==1)
                    { $temp=SALARY_1; }
                    if($job['jobs']['salary']==2)
                    { $temp=SALARY_2; }
                    if($job['jobs']['salary']==3)
                    { $temp=SALARY_3; }
                    if($job['jobs']['salary']==4)
                    { $temp=SALARY_4; }
                    echo "<td>".$temp."</td>";
                    
                    echo "<td>".$ajax->link('[ Apply ]', array('controller'=>'applicants','action'=>'apply_ajax',$job['jobs']['id']), array('update'=>'slip','complete'=>"make_slip();"));
                    echo " &nbsp".$html->link("<img src='img/clipboard2.gif'>", array('controller'=>'clipboards','action'=>'save',$job['jobs']['id']),array(),false,false);
                    echo "</td>";                    
                    //echo "<td>".$html->link('[ Apply ]',array('controller'=>'applicants','action'=>'apply',$job['jobs']['id']))."</td>";
                    echo "</tr>";
                }
            echo "<tr><td colspan='6' style='text-align:left; border:none'>".$html->link('[ Lihat semua lowongan yang direkomendasikan ]',array('controller'=>'assistants','action'=>'result'),array('class'=>'sky'))."</td></tr>";
            echo "</table>";            
            echo "<br>";
        }
    }
    else
    {
        echo ":. Call your assistant <b>NOW</b> to help you filter the incoming jobs. ".$html->link('[ Call Now ]',array('controller'=>'assistants','action'=>'index'),array('class'=>'sky'));
    }
    
    echo "<div class='kotak3'>";
    echo "<h4>Jobs Alert</h4>";
    echo "<span class='info'> Untuk pengaturan masuk alert pekerjaan Anda melalui email dan pengaturan profil asisten Anda</span><br>";
    
    if($assistant['status']==0)
    {  echo $html->link('[ Call Assistant ]',array('controller'=>'assistants','action'=>'index'),array('class'=>'sky')); }
    else
    { 
        echo $html->link('[ Edit Criteria ]',array('controller'=>'assistants','action'=>'index'),array('class'=>'sky'));
        echo "&nbsp &nbsp ";
        echo $html->link('[ View Result ]',array('controller'=>'assistants','action'=>'result'),array('class'=>'sky'));
    }
    echo "<center><hr width='99%' color='#ccc' style='margin-top:10px'></center>";
    
    echo "<h4>Resume Status</h4>";
    echo "<span class='info'> Simpan resume Anda dan Anda dapat menerapkan pekerjaan online dengan langkah mudah </span><br>";

    echo "<table>";
        echo "<tr><td width='180px' ><b>Resume Type</b></td><td width='180px'><b>Status</b></td><td width='220px'></td>";
        echo "<tr><td>Resume online</td>";
            $complete = $this->requestAction(array('controller'=>'jobseekers','action'=>'complete_all'),array('class'=>'sky'));
            if($complete)
            { 
                echo "<td><b><font color='#22f'>Created</font></b></td>";
                echo "<td>".$html->link('[ Edit ]', array('controller' => 'jobseekers','action' => 'personal_detail'),array('class'=>'sky'))." &nbsp"; 
                echo $html->link('[ View ]', array('controller' => 'resumes','action' => 'view','id' => $resume['resumes']['id']),array('class'=>'sky'))."</td>";  
            }
            else
            { 
                echo "<td><b><font color='#f22'>Not Created</font></b></td>";
                echo "<td>".$html->link('[ Create ]', array('controller' => 'jobseekers','action' => 'personal_detail'),array('class'=>'sky'))."</td>"; 
            }        
        echo "</tr>";
        echo "<tr><td>Resume attachment</td>";
            if($resume['resumes']['upload_file'])
            { 
                echo "<td><b><font color='#22f'>Created</font></b></td>";
                echo "<td>".$html->link('[ Here ]','../app/webroot/'.$resume['resumes']['upload_file'],array('class'=>'sky'),false,false)." &nbsp";

                echo $html->link('[ Edit ]', array('controller' => 'resumes','action' => 'attachment'),array('class'=>'sky'))." &nbsp";
                echo $html->link('[ Delete ]',array('controller'=>'resumes','action'=>'delete_attachment'),array('class'=>'sky'),"Are you sure want to delete your attachment resume?");
            }
            else
            { 
                echo "<td><b><font color='#f22'>Not Created</font></b></td>";
                echo "<td>".$html->link('[ Create ]', array('controller' => 'resumes','action' => 'attachment'),array('class'=>'sky'))."</td>"; 
            }        
        echo "</tr>";
        echo "<tr valign='top'><td>Level yang bisa dicari</td>";
            if($resume['resumes']['open'])
            {  echo "<td><b><font color='#22f'>Open</font></b><br><span class='info'> Viewed <b>".$resume['resumes']['views']."</b> time(s)</span></td>"; }
            else
            { echo "<td><b><font color='#f22'>Hide</font></b><br><span class='info'> Viewed <b>".$resume['resumes']['views']."</b> time(s)</span></td>"; }
            echo "<td>".$html->link('[ Edit ]', array('controller' => 'resumes','action' => 'searchable'),array('class'=>'sky'))."</td>"; 
        echo "</tr>";
    echo "</table>";
    echo "<center><hr width='99%' color='#ccc' style='margin-top:10px'></center>";
        
       
    echo "<h4>Applications</h4>";
    $new = $this->requestAction(array('controller'=>'applicants','action'=>'new_reply')); 
    echo "Anda telah memiliki <b>".$applicants."</b> lowongan(s) online. ";
    if($new)
    { echo "<span class='red'><sup>New Repply</sup></span>"; }
    echo "<br>".$html->link('[ Lihat semua aplikasi ]',array('controller'=>'applicants','action'=>'my_applications'),array('class'=>'sky'));
    echo "<center><hr width='99%' color='#ccc' style='margin-top:10px'></center>";
    
    echo "<h4>Clipboards</h4>";
    echo "Anda telah menyimpan <b>".$clipboards."</b> lowongan(s)";
    echo "<br>".$html->link('[ Lihat semua clipboards ]',array('controller'=>'clipboards','action'=>'my_clipboards'),array('class'=>'sky'));
    
    echo "</div>";
    
     
echo "</div>"; 
echo "<div id='slip'></div>";    
?>


